<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01起步</title>
    <script src="./../vue/vue.js"></script>
    <script src="./../vue/vue-router.js"></script>
</head>
<body>

    <div id="app">

        <div>
            Hello Vue Router
        </div>

        <div>
            <ul>
                <router-link to="/">首页</router-link>
                <router-link to="/test">test</router-link>
            </ul>
        </div>

        <div>
            <router-view></router-view>
        </div>

        
    </div>

    <script>

        let foo = {
            props: ["test"],
            data: function(){
                return {
                    name: "你好"
                }
            },
            template: `
            <div>{{ name }}</div>
            `
        }

        let bar = {
            props: ["test"],
            data: function(){
                return {
                    name: "你好Test"
                }
            },
            template: `
            <div> bar </div>
            `
        }

        const router = new VueRouter({
            routes: [
                {path: '/',component: foo },
                {path: '/test',component: bar }
            ]
        })
        
        let vm = new Vue({
            router,
            el: "#app",
            data: {

            },
            methods: {
                
            },
            components: {
                'component-a': foo
            }
        })
    </script>
    
</body>
</html>